package com.bruce.commonutils;

import android.util.Log;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by Bruce-Home on 2015/8/23.
 */
public class UrlUtils {
    public static String getEndPoint(String urlStr) {
        try {
            URL url = new URL(urlStr);
            String path = url.getPath();
            String retHost = urlStr.replace(path, "");
            Log.d("bruce", "ret host = " + retHost);
            return retHost;

        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static String getPath(String urlStr) {
        try {
            URL url = new URL(urlStr);
            String ret = url.getPath().substring(1);
            Log.d("bruce", "ret path = " + ret);
            return ret;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        return "";
    }
}
